#!/usr/bin/perl
use FindBin;
use lib "$FindBin::Bin/../pllib/lib/perl5";
use lib "$FindBin::Bin/../lib";

use strict;
use POSIX qw(strftime);
use IO::File;
use JSON;
use Getopt::Long;

sub usage {
    my $pname = $FindBin::Script;

    print("$pname <disk text1> <disk text2> ...\n");
    exit(1);
}

sub main {
    my $allDisksTxt = '';
    foreach my $disksTxt (@ARGV) {
        $disksTxt =~ s/\\n/\n/sg;
        $disksTxt =~ s/^\s*|\s*$//sg;
        $allDisksTxt = $allDisksTxt . "\n" . $disksTxt;
    }
    my $hasError = 0;

    $allDisksTxt =~ s/^\s*|\s*$//sg;
    if ( $allDisksTxt eq '' ) {
        print("WARN: Disks list is empty.\n");
    }
    else {
        foreach my $diskPath ( split( "\n", $allDisksTxt ) ) {
            if ( -e $diskPath ) {
                system("dd bs=64k count=1 if=/dev/zero of=$diskPath");
            }
            else {
                print("WARN: Disk dev:$diskPath not exists.\n");
            }
        }
    }

    return $hasError;
}

exit main();
